//#include "iostream";
//#include <stdio.h>;
//#include <string>
//#include <QDebug>;
//#include <stdlib.h>;
//#include <cstdlib>;
//#include <QString>;
#include "db_manager.h";
#include "users.h";
#include "extraclass.h";

typedef unsigned int uint32_t;
using namespace std;

//
//			http://wiki.linuxformat.ru/index.php/LXF89:PostgreSQL
//			http://doxygen.postgresql.org/libpq-fe_8h.html
//
//

int main( /*int argc, char * argv[ ]*/ )
{

	db_manager * dbm = new db_manager( );

	cout << "удаляем БД\t" << dbm-> db_clean( ) << endl;
	cout << "создаем БД\t" << dbm-> db_create( ) << endl;

//	dbm-> new_user( "alexander", "12345" );
//	dbm-> new_user( "alex", "123" );
//	dbm-> new_user( "alex2", "222" );
//	dbm-> new_user( "ivan", "ivan-one" );


	dbm-> Test( );














//	int t, tt;
////	dbm-> find_user( "alex2", t );
////	cout << t << endl << endl;



////	cout << dbm-> GetSession( "ivan", "ivan-on__" , t ) << endl;
////	cout << "main( ) t = " << t << endl;

//	cout << dbm-> GetSession( "ivan", "ivan-one" , t ) << endl;
//	cout << "main( ) t = " << t << endl;

////	cout << dbm-> GetSession( "ivan", "ivan-one" , t ) << endl;
////	cout << "main( ) t = " << t << endl;

//	cout << dbm-> GetSession( "alex", "123" , t ) << endl;
//	cout << "main( ) t = " << t << endl;

//	cout << dbm-> GetSession( "alexander", "12345" , t ) << endl;
//	cout << "main( ) t = " << t << endl;

//	cout << dbm-> GetSession( "alex2", "222" , t ) << endl;
//	cout << "main( ) t = " << t << endl;

//	cout << "main( ) " << dbm-> GetIduser( t, tt ) << endl;
//	cout << "main( ) t = " << tt << endl;



//	cout << "main( ) " << dbm-> NewMessage( 2, 3, "123" ) << endl;
//	cout << "main( ) " << dbm-> NewMessage( 2, 3, "qwertyuiopasdfghjklmnbvcxz" ) << endl;

////	stringstream s;
////	s << "+100500";
////	cout << "&s = " << &s << endl;

//	char * s;
//	ExtraClass :: GetString( s, "01234567", "890", "W" );
//	cout << endl << s << endl;

//	dbm-> Test( );

	// проводим тест.


	/*
	int t = 100500;

	Users u;
//	cout << u. Clean( ) << endl;
//	cout << u. Create( ) << endl;

	cout << u. InsRecord( "alex", "pass" ) << endl;
	cout << u. InsRecord( "alex", "pass123" ) << endl;
	cout << u. InsRecord( "alexander", "pass" ) << endl;

	cout << u. FindRecord( "alex", t ) << endl;
	cout << "\t" << t << endl;
	cout << u. FindRecord( "alexander", t ) << endl;
	cout << "\t" << t << endl;
	cout << u. FindRecord( "1", t ) << endl;
	cout << "\t" << t << endl;
	cout << u. FindRecord( "NULL", t ) << endl;
	cout << "\t" << t << endl;

//	cout << u.Clean( ) << endl;
	*/




/*
cout << htable_hash( "053483583214983", 15 ) << endl;
cout << htable_hash( "820157627948527", 15 ) << endl;

cout << htable_hash( "50956", 5 ) << endl;
cout << htable_hash( "11892", 5 ) << endl;
*/


/* pass
"1049833186"
"1084959421"
"1159416674"
"1208442674"
"1256150486"
"1258112950"
"1360749122"
"1367725171"
"1404942150"
"1460334401"
"1685943862"
"1707834535"
"1879051579"
"1984665194"
"2072584961"
"2206218427"
"2265501906"
"2327011051"
"2372308667"
"2555010511"
"2832854693"
"3085113756"
"3278189236"
"3312924692"
"3314365680"
"3381345524"
"3453386375"
"3455928292"
"3488633158"
"3527660749"
"360569664"
"3740854328"
"3757928512"
"3785063454"
"3795251603"
"3852006671"
"3858726244"
"3933505102"
"3939420371"
"3955688311"
"4123280564"
"4173734641"
"423893510"
"4260407242"
"571176399"
"670994741"
"671174004"
"709880961"
"734857186"
"740723209"
"752192275"
"871714600"
"881767709"
*/



	/*
	srand ( time(NULL) );

	const int n = 10;


	char c1;
	int rnd;

	for( int i = 0; i < 10000000; i++ )
	{
		char c [ n ] = "";
		char pass [ 11 ]= "";
		for( int k = 0; k < n - 1; k++ )
		{
			rnd = rand( ) % 10;
			c1 = rnd + 48;
			strncat( c , & c1, 1 );
		}
		sprintf( pass, "%u", htable_hash( c, strlen( c ) ) );
		cout << c << "\t" << pass << "\t" << i << endl;
		u. InsRecord( c, pass );
	}
	*/


//	cout << ch << "\t" << strlen( ch ) << "\t" << htable_hash( ch, strlen( ch ) ) << endl;

//SELECT pass,pass FROM users group by pass, pass having count(*)>1;
//SELECT login from users where pass = '3785063454';

	return 0;
}
